import JSEncrypt from './jsencrypt.js'
export const RSA = {
	// RSA 加密
	RSAEncryptLong(d) {
	  d = encodeURIComponent(d);
	  let encrypt = new JSEncrypt();
	  let publicKey ="MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC0AUXL1ul5FB+TjBB/C68xi/BFTFI5UZym6xKGVA6lKA2iPdQK34WGzWSrZFpZR5znZ9u63vTEUcsk959csEnkGxD6FRupU0LgH7Eq6nSv5NLZrMZFswaiVnf0i/TT9n48RqdDuJ3NqcucFcvk+lspkISv77J5O2Lnjrk7MVcugwIDAQAB";
	  encrypt.setPublicKey(publicKey);
	  let maxLength = 117;

	  try {
	    let lt = "";
	    let ct = "";

	    if (d.length > maxLength) {
	      lt = d.match(/.{1,117}/g);
	      //    // //console.log(lt)
	      lt.forEach(function(entry) {
	        let t1 = encrypt.encrypt(entry);
	        ct += t1;
	        //      // //console.log(ct);
	      });
	      return ct
	    }
	    let t = encrypt.encrypt(d);
	    let y = t
	    return y;
	  } catch (ex) {
	    return false;
	  }
	}
}
// // RSA 加密
// 	function RSAEncryptLong(d) {
// 	  d = encodeURIComponent(d);
// 	  let encrypt = new JSEncrypt.JSEncrypt();
// 	  let publicKey ="MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDT4YYDA9M0c22E24+fEDI68Qm2j0D+8UUkGPv3PsOEKmMgfO9ReaLm9bMCjG9JcJPI6fIGOJYu1J7fzhgjlWG9XnWHrfPPFUNg96dcsEoMCCCb2XBfXRxQlm8VdrMoa8nkCpnCPn3hxKqOJOnYMwAbLav8yWj+e1ln+EYLr/Xz0wIDAQAB";
// 	  encrypt.setPublicKey(publicKey);
// 	  let maxLength = 117;

// 	  try {
// 	    let lt = "";
// 	    let ct = "";

// 	    if (d.length > maxLength) {
// 	      lt = d.match(/.{1,117}/g);
// 	      //    // //console.log(lt)
// 	      lt.forEach(function(entry) {
// 	        let t1 = encrypt.encrypt(entry);
// 	        ct += t1;
// 	        //      // //console.log(ct);
// 	      });
// 	      return ct
// 	    }
// 	    let t = encrypt.encrypt(d);
// 	    let y = t
// 	    return y;
// 	  } catch (ex) {
// 	    return false;
// 	  }
// 	}
// 	function toast(){
		
// 	}
	// module.exports = {
	// 	RSAEncryptLong,
	// 	toast
	// }
